package com.cssy.xxkj.logic.dao.impl;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.xxkj.logic.dao.LogicMaterialBackDAO;
import com.cssy.xxkj.logic.entity.LogicMaterialBackDO;
import com.plat.helper.SearchConditions;

public class LogicMaterialBackDAOImpl extends SqlMapClientDaoSupport implements
	LogicMaterialBackDAO {
	
	/**
     * 插入数据
     * @param logicMaterialBackDO
     * @return 插入数据的主键
     */
    public String insertLogicMaterialBackDO(LogicMaterialBackDO logicMaterialBackDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("LogicMaterialBack.insert", logicMaterialBackDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicMaterialBackDO
     * @return 查出的记录数
     */
    public Integer countLogicMaterialBackDOByExample(LogicMaterialBackDO logicMaterialBackDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicMaterialBack.countByDOExample", logicMaterialBackDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicMaterialBackDO
     * @return 受影响的行数
     */
    public Integer updateLogicMaterialBackDO(LogicMaterialBackDO logicMaterialBackDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicMaterialBack.update", logicMaterialBackDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicMaterialBackDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicMaterialBackDO> findListByExample(LogicMaterialBackDO logicMaterialBackDO) throws DataAccessException {
        List<LogicMaterialBackDO> list = getSqlMapClientTemplate().queryForList("LogicMaterialBack.findListByDO", logicMaterialBackDO);
        return list;
    }

    /**
     * 根据主键获取logicMaterialBackDO
     * @param id
     * @return logicMaterialBackDO
     */
    public LogicMaterialBackDO findLogicMaterialBackDOByPrimaryKey(String id) throws DataAccessException {
        LogicMaterialBackDO logicMaterialBackDO = (LogicMaterialBackDO) getSqlMapClientTemplate().queryForObject("LogicMaterialBack.findByPrimaryKey", id);
        return logicMaterialBackDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicMaterialBackDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicMaterialBack.deleteByPrimaryKey", id);
        return rows;
    }

	@Override
	public List<LogicMaterialBackDO> find(SearchConditions scs)
			throws DataAccessException {
		List<LogicMaterialBackDO> list = getSqlMapClientTemplate().queryForList("LogicMaterialBack_ex.find", scs);
        return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicMaterialBack_ex.count", scs);
        return count;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().update("LogicMaterialBack_ex.deleteBizRemoved", id);
        return count;
	}
}
